<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/mall/gift/list" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zpmc'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="giftNames" placeholder="<fmt:message key='qsrzpmc'/>" value="<c:if test='${params.giftNames !=null}'>${params.giftNames}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="0"><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.status == 1}">selected</c:if>><fmt:message key='ysj'/></option>
                                <option value="2" <c:if test="${params.status == 2}">selected</c:if>><fmt:message key='yxj'/></option>
                                <option value="3" <c:if test="${params.status == 3}">selected</c:if>><fmt:message key='dsh'/></option>
                                <option value="4" <c:if test="${params.status == 4}">selected</c:if>><fmt:message key='shtg'/></option>
                                <option value="5" <c:if test="${params.status == 5}">selected</c:if>><fmt:message key='shbtg'/></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='sj'/></label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" readonly class="layui-input" value="${params.beginDateOfValidity}" name="beginDateOfValidity" id="beginDateOfValidity">
                            </div>
                            <div class="layui-form-mid"> - </div>
                            <div class="layui-input-inline">
                                <input type="text" readonly class="layui-input" value="${params.endDateOfValidity}" name="endDateOfValidity" id="endDateOfValidity">
                            </div>
                        </div>
                    </div>

                    <input type="hidden" name="status" value="${params.status}"/>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

<%--            <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" id="add"><i class="layui-icon">&#xe61f;</i> 添加</a>--%>
            <%--<a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="putaways"><i class="layui-icon">&#xe605;</i> 批量申请上架</a>--%>
            <%--<a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-danger" id="soldouts"><i class="layui-icon">&#x1006;</i> 批量下架</a>--%>

            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th width="5%"><input id="checkboxs" type="checkbox" lay-ignore lay-skin="primary"/></th>
                    <th><fmt:message key='zpmc'/></th>
                    <th><fmt:message key='zptp'/></th>
                    <th><fmt:message key='sysp'/></th>
                    <th><fmt:message key='mkje'/></th>
                    <th><fmt:message key='yxq'/></th>
                    <th><fmt:message key='cjsj'/></th>
                    <th><fmt:message key='zt'/></th>
                    <th><fmt:message key='cz'/></th>
                </tr>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td><input type="checkbox" value="${item.id}" class="feijin-check" lay-ignore lay-skin="primary"/></td>
                        <td>
                                ${item.name}
                        </td>
                        <td>
                            <c:forEach items="${fn:split(item.giftImages, ';')}" var="image">
                                <img style="width:30px;height:30px;" src="${store_domain}/uploads/${image}"/>
                            </c:forEach>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.scopeGoodsType eq 1}"><fmt:message key='sysp1'/></c:when>
                                <c:when test="${item.scopeGoodsType eq 2}"><fmt:message key='zdsp'/></c:when>
                                <c:when test="${item.scopeGoodsType eq 3}"><fmt:message key='zdfl'/></c:when>
                            </c:choose>
                        </td>
                        <td><fmt:formatNumber value="${item.standardsAmount}" type="CURRENCY"/></td>
                        <td>${item.beginDateOfValidity} - ${item.endDateOfValidity}</td>
                        <td>${item.createTime}</td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><fmt:message key='ysj'/></c:when>
                                <c:when test="${item.status eq 2}"><fmt:message key='yxj'/></c:when>
                                <c:when test="${item.status eq 3}"><fmt:message key='dsh'/></c:when>
                                <c:when test="${item.status eq 4}"><fmt:message key='shtg'/></c:when>
                                <c:when test="${item.status eq 5}"><fmt:message key='shbtg'/></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <div class="layui-btn-container">

                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ck'/></a>

                                <c:choose>
                                    <c:when test="${item.status eq 3}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-process"><fmt:message key='sh'/></a>
                                    </c:when>
                                </c:choose>


                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['laydate', 'layer', 'form'], function() {
        var laydate = layui.laydate;
        var layer = layui.layer;

        laydate.render({
            elem: "#beginDateOfValidity",
            type: "date"
        });

        laydate.render({
            elem: "#endDateOfValidity",
            type: "date"
        });

        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });

        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckxq'/>'
                , content: '${web_domain}/mall/gift/' + id + '/detail'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh'/>']
            });
        });


        //审核
        $(".feijin-process").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='shzphd'/>'
                , content: '${web_domain}/mall/gift/' + id + '/process'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='bc'/>', '<fmt:message key='qx'/>']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

    });

</script>
</body>
</fmt:bundle>
</html>
